//最新
function fmMentalityData(){
	$.ajax({
		url:"../json/FmArticleAction_fmMentalityData?t="+new Date(),
		dataType:"json",
		type:"post",
		success:function(data){
			var str="";
			$.each(data.obj,function(index,item){
				str+='<li><a href="javaScript:getData('+item.fid+')"  class="fillmoreright1_contents_img">'+
            		'<img  src="../'+item.faddr+'"/></a><div ><a href="javascript:getData('+item.fid+')">'+
            		'<span style="color:#000">'+item.fname+'</span></a><br/><span>作者：'+item.fauthor+'</span><br/>'+
            		'<span>播出时间：'+item.ftime+'<span></div></li>';
			})
			$(".DataArticle").html(str);
		}
		
	});
}
//用户点击某一个音频时
function getData(id){
	$.ajax({
		url:"../json/FmArticleAction_change",
		dataType:"json",
		type:"post",
		data:{
			'fid':id
		},
	success:function(data){
		if(data.result>0){
			location.href="FM_mentality.jsp";
		}
	}
	});
}
//对于用户查询一个类型时的处理
function typeArticle(type){
	$.ajax({
		url:"../json/FmArticleAction_typeArticle",
		dataType:"json",
		type:"post",
		data:{
			'ftype':type
		},
		success:function(data){
			var obj="";
			alert(type);
			if(type=="烦躁"){
				obj=$(".findWhiny");
			}else if(type=="孤独"){
				obj=$(".findlone");
			}else if(type="悲伤"){
				obj=$(".findsad");
			}else if(type=="快乐"){
				alert("gggg");
				obj=$(".findhappy");
			}else if(type="迷忙"){
				
				obj=$(".findlost");
			}else if(type=="感动"){
				obj=$(".findmove");
			}
			var str="";
			$.each(data.rows,function(index,item){
				str+='<li><a href="javaScript:getData('+item.fid+')"  class="fillmoreright1_contents_img">'+
            		'<img  src="../'+item.faddr+'"/></a><div ><a href="javascript:getData('+item.fid+')">'+
            		'<span style="color:#000">'+item.fname+'</span></a><br/><span>作者：'+item.fauthor+'</span><br/>'+
            		'<span>播出时间：'+item.ftime+'<span></div></li>';
			});
			obj.html(str);
		}
	});
}
//对于点赞事件的处理
function fmArticleGood(fid){
		var backgroundImag=$("#contents_fillmore_class2").css("background-position");
		$.ajax({
			url:"../json/FmArticleAction_fmArticleGood",
			dataType:"json",
			type:"post",
			data:{
				'fid':fid
			},
			success:function(data){
				if(data.result==1){
					$(".log_user").css("display","block");
					$(".log_user_info").css("display","block");
				}else {
					var background=$("#contents_fillmore_class2").css("background-position");
					if('0px -18px'==background){
						$("#contents_fillmore_class2").css("background-position","0px -80px");
					}else if('0px -80px'==background){
						$("#contents_fillmore_class2").css("background-position","0px -18px");
					}
				}
			}
		});
}
//对于用户收藏
function fmArticleGet(fid){
	var backgroundImag=$("#contents_fillmore_class3").css("background-position");
	$.ajax({
		url:"../json/FmArticleAction_fmArticleGet",
		dataType:"json",
		type:"post",
		data:{
			'fid':fid
		},
		success:function(data){
			if(data.result==1){
				$(".log_user").css("display","block");
				$(".log_user_info").css("display","block");
			}else {
				var background=$("#contents_fillmore_class3").css("background-position");
				if('0px -18px'==background){
					$("#contents_fillmore_class3").css("background-position","0px -80px");
				}else if('0px -80px'==background){
					$("#contents_fillmore_class3").css("background-position","0px -18px");
				}
			}
		}
	});
}
//查看用户评论
function findComment(fid){
	$.post("../json/FmArticleAction_findComment?t="+new Date(),{'userComment.objid':fid,},function(data){
		var str="";
		$.each(data.rows,function(index,item){
			str+='<li style="border-bottom:1px #E1E1E1 dashed"><a class="FM_img"><img src="../images/userlogin.jpg"/></a><div class="mentality_div"><a>用户'+item.w_uid+'</a><br/><a>'+item.ccontent+'</a><p>'+item.ctime+'</p></div></li>';
		});
		$("#fillmorerights_contents_ul").html(str);
	},"json");
}
//对于用户评论
function content(fid){
	var contents=replace_em($("#fillmorerights_contents_textarea").val());
	if(contents!=""){
		$.ajax({
			url:"../json/FmArticleAction_findContent",
			dataType:"json",
			type:"post",
			data:{
				'userComment.objid':fid,
				'userComment.ccontent':contents
			},
			success:function(data){
				var str="";
				if(data.result==1){
					$(".log_user").css("display","block");
					$(".log_user_info").css("display","block");
				}else{
					$.each(data.rows,function(index,item){
						str+='<li style="border-bottom:1px #E1E1E1 dashed"><a class="FM_img"><img src="../images/userlogin.jpg"/></a><div class="mentality_div"><a>用户'+item.w_uid+'</a><br/><a>'+item.ccontent+'</a><p>'+item.ctime+'</p></div></li>';
					});
					$("#fillmorerights_contents_ul").html(str);
					$("#fillmorerights_contents_textarea").val("");
					
				}
			}
		});
	}
}
/**
 * 搜索
 */
function Search(){
	var contents=$(".text").val();
	if(contents!=""){
		$.ajax({
			url:"../json/FmArticleAction_search",
			dataType:"json",
			type:"post",
			data:{
				'searchContent':contents
			},
			success:function(data){
				if(data.result==1){
					var str="";
					$.each(data.rows,function(index,item){
						str+='<li><a href="javaScript:getData('+item.fid+')"  class="fillmoreright1_contents_img">'+
		            		'<img  src="../'+item.faddr+'"/></a><div ><a href="javascript:getData('+item.fid+')">'+
		            		'<span style="color:#000">'+item.fname+'</span></a><br/><span>作者：'+item.fauthor+'</span><br/>'+
		            		'<span>播出时间：'+item.ftime+'<span></div></li>';
					});
					$("#FmDim").html(str);
					
				}else if(data.result==0){
					var strs="<a style='margin-left:80px;display:block;margin-top:200px;font-size:20px;'>亲！小微没找到你想要的音频</a>";
					$("#FmDim ").html(strs);
				}
			}
		});
	}
}
/*
 *用户留言 
 */
function AllNote(){
	$.ajax({
		url:"../json/FmArticleAction_AllNote",
		dataType:"json",
		type:"post",
		success:function(data){
			var str="";
			$.each(data.rows,function(index,item){
				str+='<li style="border-bottom:1px #E1E1E1 dashed"><a class="FM_img"><img src="../images/userlogin.jpg"/></a><div class="mentality_div"><a>用户'+item.w_uid+'</a><br/><a>'+item.ccontent+'</a><p>'+item.ctime+'</p></div></li>';
			});
			$("#fillmorerights6_contents_ul").html(str);
		}
	});
}
/**
 * 添加留言
 */
function addNote(){
	var contents=$("#fillmorerights6_contents_textarea").val();
	$.ajax({
		url:"../json/FmArticleAction_addNote",
		dataType:"json",
		type:"post",
		data:{
			'userComment.ccontent':contents
		},
		success:function(data){
			var str="";
			$.each(data.rows,function(index,item){
				str+='<li style="border-bottom:1px #E1E1E1 dashed"><a class="FM_img"><img src="../images/userlogin.jpg"/></a><div class="mentality_div"><a>用户'+item.w_uid+'</a><br/><a>'+item.ccontent+'</a><p>'+item.ctime+'</p></div></li>';
			});
			$("#fillmorerights6_contents_ul").html(str);
			$("#fillmorerights6_contents_textarea").val("");
		}
	});
	
}
/*
 * 用户登录
 */
function  submitInfo(){
	var email=$("#user_id").val();
	var pwd=$("#user_pad").val();
	
	if(email == "") {
		alert("邮箱不能为空!");
		return;
	}
	if(pwd == "") {
		alert("密码不能为空!");
		return;
	}
	$.post("../json/userInfoAction_login",{"userInfo.w_email":email,"userInfo.w_pwd":pwd},function(data){
		var result=parseInt(data.result);
		if( result== 1 ){
			$(".log_user").css("display","none");
			$(".log_user_info").css("display","none");
			 window.location.reload(); //重定后 再刷新页面 
		}else {
			 alert("用户名或密码错误!!!");
		}
	},"json");
}
